<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<%
    response.setHeader("cache-control","public");
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html>
<!-- 部门管理列表 -->
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="renderer" content="webkit">
    <title></title>
    <link rel="stylesheet" type="text/css" href="<%=path%>/static/css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="<%=path%>/static/css/common.css">
    <link rel="stylesheet" type="text/css" href="<%=path%>/static/css/style.default.css">
    <link rel="stylesheet" type="text/css" href="<%=path%>/static/css/bootstrap-table.css">
    <link rel="stylesheet" type="text/css" href="<%=path%>/static/css/examMng/paperMng.css">
    <!--bootstrap基础引用 start-->
<script type="text/javascript" src="<%=path%>/static/jstreeview/bootstrap/jquery-3.1.1.min.js"></script>
<script type="text/javascript" src="<%=path%>/static/js/bootstrap.min.js"></script>
<!--bootstrap基础引用 end-->
<!--bootstrap-dialog start-->
<link rel="stylesheet" type="text/css" href="<%=path%>/static/jstreeview/plugins/bootstrap-dialog/bootstrap-dialog.min.css">
<script type="text/javascript" src="<%=path%>/static/jstreeview/plugins/bootstrap-dialog/bootstrap-dialog.min.js"></script>
<!--bootstrap-dialog end-->
    <style>
    </style>
</head>
<body>

<jsp:include page="../head.jsp" flush="true"/>

<!--body begin-->
<div class="main-container">
    <div class="container body-box" style="padding: 0px;">
        <div class="title-top" style="background: #4c4ca6;">
            <p>单位列表：</p>
            <a class="btn btn-success addpaper" href="<%=path%>/dept/unitdata" style="background: #4c4ca6;border:solid 1px #ffffff;"><i
                    class="glyphicon glyphicon-plus-sign"></i>新增单位</a>
        </div>
        <div class="paper-content">
            <!--当前没有可用试卷 end-->
            <!--试卷列表-->
            <table id="table"></table>
        </div>
    </div>
</div>
<!--body end-->


</div>
<!--footer end-->
<script type="text/javascript" src="<%=path%>/static/jquery/jquery-1.12.2.min.js"></script>
<script type="text/javascript" src="<%=path%>/static/js/bootstrap-table.js"></script>

<script type="text/javascript" src="<%=path%>/static/js/bootstrap-table-zh-CN.js"></script>
</body>

<script type="text/javascript">

    $(function () {
        // if(role=='')
        // $('#topMain').children().eq(1).addClass('active'); // 追加样式;
        // $('#topMain').children().eq(1).children().attr('href', '#');

        //单位管理主页面
        if (${role eq 'master'}) {
            $('#topMain').children().eq(0).addClass('active'); // 追加样式;
            $('#topMain').children().eq(0).children().attr('href', '#');
        } else if (${role eq 'trainee'}) {
            $('#topMain').children().eq(0).addClass('active'); // 追加样式;
            $('#topMain').children().eq(0).children().attr('href', '#');
        } else {
            $('#topMain').children().eq(1).addClass('active'); // 追加样式;
            $('#topMain').children().eq(1).children().attr('href', '#');
        }


    })

    function AddFunctionAlty(value, row, index) {
        return [
            '<button id="edit",type="button" class="btn btn-default">编辑</button>&nbsp;' +
            '<button id="del",type="button" class="btn btn-default">删除</button>'
        ].join("")
    }

    window.operateEvents = {
        'click #edit': function (e, value, row, index) {
            window.location.href = "<%=path%>/dept/unitdata?id=" + row.id;

        }, 'click #del': function (e, value, row, index) {
          	BootstrapDialog.confirm({
				title : '提示',
				message : '确定删除此单位?',
				size : BootstrapDialog.SIZE_SMALL,
				type : BootstrapDialog.TYPE_DEFAULT,
				closable : true,
				btnCancelLabel : '取消',
				btnOKLabel : '确定',
				callback : function(result) {
					if(result){
					    $.ajax({
			                type:"post",
			                data:{id:row.id},
			                url:"<%=path%>/dept/delpaper",
			                success:function (data) {
			                	BootstrapDialog.confirm({
			        				title : '提示',
			        				message : '删除成功',
			        				size : BootstrapDialog.SIZE_SMALL,
			        				type : BootstrapDialog.TYPE_DEFAULT,
			        				closable : true,
			        				btnCancelLabel : '取消',
			        				btnOKLabel : '确定',
			        				callback:function(result){
			        					 window.location.href = "<%=path%>/dept/unitindex";
			        				}
			        			});
			                   

			                }
			            })
					}
				}
			});

        
            //判断是否添加

        }
    };

    $('#table').bootstrapTable({
        "pagination": true,
        "search": true,
        method: 'post',
        dataType: 'json',
        contentType: "application/x-www-form-urlencoded",
        url: '/examsys/dept/dataList',
        striped: true,
        toolbar: "#toolbar",
        showHeader: true,
        pageNumber: 1,
        showRefresh: true,                  //是否显示刷新按钮
        pagination : true,//是否分页
        sidePagination : 'client',//server:服务器端分页|client：前端分页
        pageSize : 4,//单页记录数
        pageList : [ 5, 10, 20, 30 ],//可选择单页记录数
        columns: [{
            field: 'number',
            title: '序号',
            align: "center",
            valign: "middle",
            formatter: function (value, row, index) {
                return index + 1;
            }
        }, {
            field: 'identifier',
            title: '编号',
            align: "center",
            valign: "middle",
            //是否启用排序
            sortable: true,
            //排序方式
            sortOrder: "desc",
        },  {
            field: 'name',
            title: '名称',
            align: "center",
            vertical: "middle"
        }, {
            field: 'code',
            title: '代码',
            align: "center",
            valign: "middle"
        }, {
            field: 'Operations',
            title: '操作',
            events: 'operateEvents',
            formatter: 'AddFunctionAlty',
            align: "center",
            valign: "middle"
        }]
    });

</script>

</html>

